<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <button data-name="西瓜" id="xigua"> 习惯

    </button>
    <button data-name="苹果" id="pinguo">
        苹果
    </button>
    <!-- <script src="./3.2.js"></script> -->
    <script>
        let xigua = document.querySelector("#xigua");
        let pinguo = document.querySelector("pinguo");
        Function.prototype.after = function (afterFn) {
            let _this = this;
            return function () {
                _this.apply(this, arguments);
                afterFn.apply(this.arguments);
            }
        }
        function click() {
            console.log(`你点击了` );
        }
        //after 返回一个新的函数，要重新赋值
        click = click.after(function () {
            console.log("点击完了~~~~~~~~~")
            // let img = new Image();
            // img.src = "http://localhost:3000/report?name="+this.dataset.name; //发给服务器端
        })

        Array.from(document.querySelectorAll("button")).forEach(button => {
            button.addEventListener("click", click)
        })

    </script>
</body>

</html>